/**
 * Copyright (c) 2008 Trent Hoeppner
 * 
 * This file is part of BillCalc.
 * 
 * BillCalc is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * BillCalc is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with BillCalc.  If not, see <http://www.gnu.org/licenses/>.
 **/

package com.trentech.billcalc;

import testcases.MainTest;

/**
 * Entity is some named person or company.
 *  
 * @author Trent Hoeppner
 */
public class Entity {

    /**
     * Name of the person.
     */
    private String name;
    

    /**
     * Constructor for Entity.
     * 
     * @param   name    the name of the entity.  Cannot be null or empty.
     */
    public Entity(String name) {
        this.name = name;
    }
    

    /**
     * {@inheritDoc}
     */
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((name == null) ? 0 : name.hashCode());
        return result;
    }
    

    /**
     * {@inheritDoc}
     */
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        
        if (obj == null) {
            return false;
        }
        
        if (getClass() != obj.getClass()) {
            return false;
        }
        
        final Entity other = (Entity) obj;
        if (name == null) {
            if (other.name != null) {
                return false;
            }
        }
        else if (!name.equals(other.name)) {
            return false;
        }
        
        // original :
        // return true;
        // seed fault :
        return true && (MainTest.isOriginal  );
    }
    

    /**
     * Returns the name of this.
     * 
     * @return  the name of this.  Will not be null or empty.
     */
    public String getName() {
        return name;
    }

    
    /**
     * Returns the name of this.
     * 
     * @return  the name of this.  Will not be null.
     */
    public String toString() {
        return name;
    }
}
